<template>
    <el-radio-group
            size="default"
            v-model="props.orm[props.item.prop]" >
        <el-radio v-if="props.item.type=='radio'"
                  :border="props.item.border ? props.item.border : false"
                  :size="props.item.size||'default'"
                  :style="props.item.style ? props.item.style : ''"
                  :disabled="props.item.disabled ? props.item.disabled : false"
                  @change=" props.item.events && props.item.events.changeSelect ? props.item.events.changeSelect($event) : null "
                  v-for="(opt,index) in options"
                  :key="index"
                  :label="(props.item.initDatas&&props.item.initDatas.value)?opt[props.item.initDatas.value]:opt.value">
                  <i
                    class="el-icon-s-flag"
                    v-if="props.item.isTag && !props.item.isAll"
                    :style="opt.color ? 'color:' + opt.color : ''"
                 />
                  <!-- {{opt.shopName}}</el-radio> -->
                  {{(props.item.initDatas&&props.item.initDatas.name)?opt[props.item.initDatas.name]:opt.label}}</el-radio>

        <el-radio-button v-if=" props.item.type == 'radio-button' "
                         size="default"
                         :disabled="props.item.disabled ? props.item.disabled : false"
                         v-for="opt in options"
                         :label="opt.value" >{{ opt.label }}</el-radio-button>
    </el-radio-group>
</template>
<script setup>
const props = defineProps({
    item :{
            required:true,
            type:Object,
        },
        form:{
            required:true,
            type:Object,
        }
})
let options=reactive([])
function getOptions(){
    var url = props.item.url;
    var param = props.item.params ;
    if(!url){return null; }
    this.$axios
        .post(url,param)
        .then(res => {
            if(res.status == 200 && res.data.code == 1){
                options = res.data.result;
                console.log(options);
            }else{
                this.$message({
                    type:"error",
                    message:'数据查询失败，请稍后重试！！！'
                });
            }
        });
}  
watch(props.item, (value) => {
  if (value.url) {
    getOptions()
  } else {
    options = value.options
  }
})
</script>
<style>

</style>










